package com.geek.stream;

import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;

public class JavaStream {

	public static List<String> list = new ArrayList<>();
	public static List<Integer> intList = new ArrayList<>();
	static {
		for (int i = 0; i < 10000; i++) {
			list.add("student_"+(i+1));
			intList.add(i);
		}
	}

	public static void main(String[] args) {
		long startTime = System.nanoTime();
//		List<String> collect = list.stream().filter(s -> true).collect(Collectors.toList());

		startTime = System.nanoTime();
		List<Long> collect1 = intList.stream().filter(i -> i > 0).map(Integer::longValue).collect(Collectors.toList());
		System.out.println(System.nanoTime() - startTime);


		startTime = System.nanoTime();
		List<Long> result = new ArrayList<>();
		for (Integer integer : intList) {
			if (integer > 0) {
				result.add(integer.longValue());
			}
		}
		System.out.println(System.nanoTime() - startTime);

		System.out.println(collect1);
		System.out.println(result);
	}

}
